/**
 * UninaDocentiSync - A Java application to synchronize Unina resources
 * Copyright (C) 2011  Fabio Scippacercola (nonplay.programmer@gmail.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

package uninadocenti.framework.synch;

import java.util.EventObject;
import java.util.logging.Level;
import uninadocenti.framework.synch.SynchingFile.State;

/**
 *
 * @author user
 */
public class SynchUpdateEvent extends EventObject {

    public SynchUpdateEvent(Object o, EventType eventType, Object payload) {
        super(o);
        this.eventType = eventType;
        this.payload = payload;
    }

    public EventType eventType;
    public Object payload;

    static public enum EventType {
        LOG_MSG, NODE_UPDATE, FOLDER_VISITED
    };

    static public class LogMessagePayload {

        public LogMessagePayload(SynchingFile f, Level level, String message, Throwable e) {
            this.f = f;
            lr = new java.util.logging.LogRecord(level, message);
            if (e != null) lr.setThrown(e);
        }

        public SynchingFile f;
        public java.util.logging.LogRecord lr;
    }

    static public class NodeUpdatePayload {

        public NodeUpdatePayload(SynchingFile f, State oldState, State newState, int fileSize) {
            this.f = f;
            this.oldState = oldState;
            this.newState = newState;
            this.fileSize = fileSize;
        }

        public SynchingFile f;
        public SynchingFile.State oldState;
        public SynchingFile.State newState;
        public int fileSize;
    }

    static public class FolderVisitedPayload {

        public FolderVisitedPayload(String folderName) {
            this.folderName = folderName;
        }

        public String folderName;
    }
}
